﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Chromely</title>
    <link rel="stylesheet" href="../Content/css/bootstrap.min.css">
    <script src="../Content/js/jquery.min.js"></script>
    <script src="../Content/js/tether.min.js"></script>
    <script src="../Content/js/bootstrap.min.js"></script>
    <script type="text/javascript">
        function messageRouterResult1(res) {
            $('#messageRouterResult1 tbody').empty();
            var jsonData = JSON.parse(res);
            if (jsonData.ReadyState == 4 && jsonData.Status == 200) {
                for (var i = 0; i < jsonData.Data.length; i++) {
                    var row = '<tr>';

                    row += '<td>' + jsonData.Data[i].Id + '</td>';
                    row += '<td>' + jsonData.Data[i].Title + '</td>';
                    row += '<td>' + jsonData.Data[i].Year + '</td>';
                    row += '<td>' + jsonData.Data[i].Votes + '</td>';
                    row += '<td>' + jsonData.Data[i].Rating + '</td>';
                    row += '<td>' + jsonData.Data[i].Date + '</td>';
                    row += '<td>' + jsonData.Data[i].RestfulAssembly + '</td>';

                    row += '</tr>';
                    $('#messageRouterResult1 tbody').append(row);
                }
            }
        }

        function messageRouterRun1() {

            $('#messageRouterResult1 tbody').html('');

            var request = {
                "method": "GET",
                "url": "/democontroller/movies",
                "parameters": null,
                "postData": null,
            };

            window.cefQuery({
                request: JSON.stringify(request),
                onSuccess: function (response) {
                    messageRouterResult1(response);
                }, onFailure: function (err, msg) {
                    console.log(err, msg);
                }
            });
        }

        function messageRouterResult2(res) {
            $('#messageRouterResult2 tbody').empty();
            var jsonData = JSON.parse(res);
            if (jsonData.ReadyState == 4 && jsonData.Status == 200) {
                for (var i = 0; i < jsonData.Data.length; i++) {
                    var row = '<tr>';

                    row += '<td>' + jsonData.Data[i].Id + '</td>';
                    row += '<td>' + jsonData.Data[i].Title + '</td>';
                    row += '<td>' + jsonData.Data[i].Year + '</td>';
                    row += '<td>' + jsonData.Data[i].Votes + '</td>';
                    row += '<td>' + jsonData.Data[i].Rating + '</td>';
                    row += '<td>' + jsonData.Data[i].Date + '</td>';
                    row += '<td>' + jsonData.Data[i].RestfulAssembly + '</td>';

                    row += '</tr>';
                    $('#messageRouterResult2 tbody').append(row);
                }
            }
        }

        function messageRouterRun2() {

            $('#messageRouterResult2 tbody').html('');

            var request = {
                "method": "GET",
                "url": "/externalcontroller/movies",
                "parameters": null,
                "postData": null,
            };

            window.cefQuery({
                request: JSON.stringify(request),
                onSuccess: function (response) {
                    messageRouterResult2(response);
                }, onFailure: function (err, msg) {
                    console.log(err, msg);
                }
            });
        }

        function messageRouterResult3(res) {
            var jsonData = JSON.parse(res);
            if (jsonData.ReadyState == 4 && jsonData.Status == 200) {
                $('#messageRouterResult3').html(jsonData.Data);
            }
        }

        function messageRouterRun3() {

            $('#messageRouterResult3').html('');

            var moviesJson = [
                { Id: 1, Title: "The Shawshank Redemption", Year: 1994, Votes: 678790, Rating: 9.2 },
                { Id: 2, Title: "The Godfather", Year: 1972, votes: 511495, Rating: 9.2 },
                { Id: 3, Title: "The Godfather: Part II", Year: 1974, Votes: 319352, Rating: 9.0 },
                { Id: 4, Title: "The Good, the Bad and the Ugly", Year: 1966, Votes: 213030, Rating: 8.9 },
                { Id: 5, Title: "My Fair Lady", Year: 1964, Votes: 533848, Rating: 8.9 },
                { Id: 6, Title: "12 Angry Men", Year: 1957, Votes: 164558, Rating: 8.9 }
            ];

            var request = {
                "method": "POST",
                "url": "/democontroller/movies",
                "parameters": null,
                "postData": moviesJson,
            };

            window.cefQuery({
                request: JSON.stringify(request),
                onSuccess: function (response) {
                    messageRouterResult3(response);
                }, onFailure: function (err, msg) {
                    console.log(err, msg);
                }
            });
        }

    </script>
</head>
<body>
  <div class="col-9 centerBlock">

		<!-- Nav pills -->
		<ul class="nav nav-pills" role="tablist">
			<li class="nav-item">
				<a class="nav-link active" data-toggle="pill" href="#sectionA">Get 1</a>
			</li>
			<li class="nav-item">
				<a class="nav-link" data-toggle="pill" href="#sectionB">Get 2</a>
			</li>
			<li class="nav-item">
				<a class="nav-link" data-toggle="pill" href="#sectionC">Post</a>
			</li>
		</ul>

		<div class="row" style="height:25px;"></div>
			
		<!-- Tab panes -->
		<div class="tab-content">
			<div id="sectionA" class="container tab-pane active">
				<br>
				<div class="row">
					<div class="col-12">
						Route Path:&ensp;/democontroller/movies &ensp; (Restful Service in Local Assembly)&ensp;<button id="buttonMessageRouterRun1" type="button" class="btn btn-primary btn-sm" onclick="messageRouterRun1()">Run</button>
					</div>
					<div style="height:100px;"></div>
					<div class="col-12">
						<div class='table-responsive'>
							<table id="messageRouterResult1" class='table'>
								<thead>
									<tr>
										<th>Id</th>
										<th>Title</th>
										<th>Year</th>
										<th>Votes</th>
										<th>Rating</th>
										<th>Date</th>
										<th>RestfulAssembly</th>
									</tr>
								</thead>
								<tbody>
								</tbody>
							</table>
						</div>
					</div>
				</div>
			</div>
			<div id="sectionB" class="container tab-pane fade">
				<br>
				<div class="row">
					<div class="col-12">
						Route Path:&ensp;/externalcontroller/movies &ensp;(Restful Service in External Assembly)&ensp;<button id="buttonMessageRouterRun2" type="button" class="btn btn-primary btn-sm" onclick="messageRouterRun2()">Run</button>
					</div>
					<div style="height:100px;"></div>
					<div class="col-12">
						<div class='table-responsive'>
							<table id="messageRouterResult2" class='table'>
								<thead>
									<tr>
										<th>Id</th>
										<th>Title</th>
										<th>Year</th>
										<th>Votes</th>
										<th>Rating</th>
										<th>Date</th>
										<th>RestfulAssembly</th>
									</tr>
								</thead>
								<tbody>
								</tbody>
							</table>
						</div>
					</div>
				</div>
			</div>
			<div id="sectionC" class="container tab-pane fade">
				<br>
				<div class="row">
					<div class="col-12">
						Route Path:&ensp;/democontroller/movies&ensp;(Restful Service in Local Assembly)&ensp;<button id="buttonMessageRouterRun3" type="button" class="btn btn-primary btn-sm" onclick="messageRouterRun3()">Run</button>
					</div>
					<div style="height:100px;"></div>
					<div class="col-12">
						<div id="messageRouterResult3"></div>
					</div>
				</div>
			</div>
		</div>


	</div>
</body>
</html>










	
